<?
    /* -*- Mode: PHP5; tab-width: 4; indent-tabs-mode: nil; basic-offset: 4 -*- */
    
    /*********************************************************
    *            --== InArch ==--
    *
    *
    * @author Kulikov Alexey <a.kulikov@gmail.com>
    * @version n/a
    * @copyright essentialmind.com 2005
    *
    *********************************************************/

    /***
    * class ajaxAddNode
    ****
    * This class will create a new node via an AJAX method
    ****
    * @package ajax
    * @author A Kulikov <a.kulikov@gmail.com>
    * @version n/a
    * @copyright essentialmind.com 2005
    ***/
    class ajaxAddToCart extends ajaxAction{

        public function process(){     
            if(!$_SESSION['CART'] or ($_SESSION['CART'] and !is_object($_SESSION['CART']))){
                $_SESSION['CART'] = new shoppingCart($this->db);
            }
                
            $this->r->itemsBefore = $_SESSION['CART']->count();
            $_SESSION['CART']->addItem((int)$_REQUEST['id'],(int)$_REQUEST['q1'],(int)$_REQUEST['q2']);                        
            $this->r->item = $_SESSION['CART']->item($_REQUEST['id']);
            $this->r->sum  = number_format($_SESSION['CART']->sum(),2,'.','');
            $this->r->discount = $_SESSION['CART']->discount();
            $this->r->total = number_format($_SESSION['CART']->price(),2,'.','');
        }
    }
?>